package wh.GameObjectFactory;

import wh.FishingPhilosopher.FishingPhilosopherActivity;
import wh.FishingPhilosopher.R;
import wh.FishingPhilosopher.Components.CannonGetTypeComponent;
import wh.FishingPhilosopher.Components.ComponentList;
import wh.FishingPhilosopher.Components.RotationOnTouchComponent;
import wh.FishingPhilosopher.GameParams.GameParams;
import wh.GameObject.FishingPhilosopherGameObject;
import android.content.Context;
import android.graphics.PointF;
import android.graphics.RectF;

public class CannonFactory {	
	public static FishingPhilosopherGameObject createCannon(Context context, int cannonType, float angle, RectF responsibleArea) {
		ComponentList componentListOfCannon=new ComponentList();
		componentListOfCannon.onTouchResponseComponent=new RotationOnTouchComponent(responsibleArea);
		componentListOfCannon.getTypeComponent=new CannonGetTypeComponent(cannonType);
		GameParams gameParams=((FishingPhilosopherActivity)context).getGameParams();
		FishingPhilosopherGameObject cannon;
		int cannonBitmap;
		switch(cannonType)
		{
			case GameParams.CANNON_HUGE:
				cannonBitmap = R.drawable.cannon5;
				break;
			case GameParams.CANNON_BIG:
				cannonBitmap = R.drawable.cannon4;
				break;
			case GameParams.CANNON_MIDDLE:
				cannonBitmap = R.drawable.cannon3;
				break;
			case GameParams.CANNON_SMALL:
				cannonBitmap = R.drawable.cannon2;
				break;
			case GameParams.CANNON_MICRO:
				cannonBitmap = R.drawable.cannon1;
				break;
			default:
				cannonBitmap = R.drawable.cannon1;
		}
		cannon=new FishingPhilosopherGameObject(context, 
				new PointF((gameParams.screenArea.width()/2)+gameParams.screenArea.left, 
						(gameParams.screenArea.height()*23/25)+gameParams.screenArea.top), 
				cannonBitmap, 
				angle, 
				false, 
				GameParams.CANNON_WIDTH, 
				GameParams.CANNON_HEIGHT);		
		cannon.setComponentList(componentListOfCannon);
		return cannon;
	}

}
